package threadUtils.demo05;

import java.util.concurrent.Phaser;

public class PhaserExample02 {

    public static void main(String[] args) {

        final Phaser phaser = new Phaser(2) {
            @Override
            protected boolean onAdvance(int parse, int registeredParties) {
                return parse >= 1;
            }
        };

        phaser.arrive();
        phaser.arrive();
        System.out.println(phaser.getPhase() == 1);
        System.out.println(phaser.isTerminated());

        phaser.arrive();
        phaser.arrive();
        System.out.println(phaser.getPhase());
    }

}
